package ca.jsbr.tinyUI.container 
{
	import ca.jsbr.as2js_lib.display.canvas.Node2D;
	import ca.jsbr.as2js_lib.display.canvas.view.ShapeView;
	/**
	 * ...
	 * @author jsbr [jsricard@lvlstudio.com]
	 */
	public class Box extends Node2D
	{
		protected var _shape:ShapeView;
		public var width:Number;
		public var height:Number;
		
		public function Box() 
		{
			super();
			_shape = new ShapeView();
			width = 100;
			height = 100;
			
			super.addChild(_shape);
		}
		
		override public function get parent():Node2D 
		{
			return _parent;
		}
		
		override public function set parent(value:Node2D):void 
		{
			_parent = value;
			draw();
		}
		
		
		protected function draw():void
		{
			_shape.clear();
			_shape.beginGradientFill(["#FFFFFF", "#DDDDDD"], [0, 1]);
			_shape.lineStyle(1, "#CCCCCC");    
			_shape.drawRect(0, 0, width, height);
			_shape.endFill();
			/*graphics.clear();
			var matrix:Matrix = new Matrix(); 
			matrix.createGradientBox(_width, _height, (Math.PI / 180) * 90, 0, 0);
			graphics.lineStyle(1, style.boxBorderColor);
			graphics.beginGradientFill(GradientType.LINEAR, style.boxColor, [1, 1], [0, 255], matrix);
			graphics.drawRect(0, 0, _width, _height);*/
		}
		
		public function redraw(child:Boolean=false):void 
		{
			draw();
			//super.redraw(child);
			if (child)
			{
				var len:Number = _childs;
				for (var i:int; i < len; i++)
				{
					if (_childs[i].redraw)
					{
						_childs[i].redraw(child);
					}
				}
			}
		}
		
	}

}